<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function () {
      // xhr.readyState，5种状态
      // 0:未初始化，未调用open
      // 1:调用了open，未调用send
      // 2:调用了send，未收到响应
      // 3:接收响应中
      // 4:完成响应
      if (xhr.readyState === 4) {
        if ((xhr.status === 200 && xhr.status < 300) || xhr.status === 304) {
          console.log(xhr.responseText)
        } else {
          console.log(`unsuccessful:${xhr.status}`)
        }
      }
    }
    xhr.open("get", "http://localhost:3000/riskArea/getSubList", true);
    xhr.setRequestHeader('MyHeader', 'MyValue')
    xhr.send(null);
    xhr.abort();
  </script>
</body>

</html>